/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dartstools.interfaces;

import dartstools.Theme;
import java.awt.Font;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.AbstractListModel;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 *
 * @author Chris
 */
public class PlayerPanel extends javax.swing.JPanel {

    private final String playerName;
    private final int targetScore;
    private DartPanel[] dartPanels = new DartPanel[3];
    private int groupScoreValue, currentTargetValue, newTargetValue;
    private boolean isBust;
    private ScoreListModel scoreListModel = new ScoreListModel();

    /**
     * Creates new form PlayerPanel
     */
    public PlayerPanel(final String name, int targetScore) {
        this.playerName = name;
        this.targetScore = targetScore;
        newTargetValue = targetScore;
        initComponents();
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
//                PlayerPanel.this.name.setMaximumSize(PlayerPanel.this.name.getVisibleRect().getSize());
//                PlayerPanel.this.name.setPreferredSize(PlayerPanel.this.name.getVisibleRect().getSize());
//                PlayerPanel.this.name.setSize(PlayerPanel.this.name.getVisibleRect().getSize());
//                PlayerPanel.this.name.setText(name);
            }

        });
        previousThrowsScroller.getViewport().setOpaque(false);
        this.dartPanels[0] = dartPanel1;
        this.dartPanels[1] = dartPanel2;
        this.dartPanels[2] = dartPanel3;
        SpinnerListener sl = new SpinnerListener();
        for (DartPanel dp : dartPanels)
            dp.getSpinner().addChangeListener(sl);
    }

    private class ScoreListModel extends AbstractListModel {

        ArrayList<DartThrowGroup> scoreData = new ArrayList<>();
        int rowWidth;

        void logScore() {
            currentTarget.setText(String.valueOf(newTargetValue));
            int d1 = dartPanel1.getSpinnerValue();
            int d2 = dartPanel2.getSpinnerValue();
            int d3 = dartPanel3.getSpinnerValue();
            DartThrowGroup dtg = new DartThrowGroup(
                    d1, dartPanel1.getModifier(),
                    d2, dartPanel2.getModifier(),
                    d3, dartPanel3.getModifier(),
                    newTargetValue);
            scoreData.add(0, dtg);
            fireContentsChanged(this, 0, 0);
        }

        @Override
        public int getSize() {
            return scoreData.size();
        }

        @Override
        public String getElementAt(int index) {
            DartThrowGroup dtg = scoreData.get(index);
            String s = "<html><table style=\"margin-left:10;"
                    //                    + "font-family:" + Theme.FONT_FAMILY
                    + "width:" + (previousThrows.getVisibleRect().getWidth() - 20) + "\""
                    + "cellspacing=\"1\" cellpadding=\"0\">"
                    + "<tr style=\"color:#ffffff\">"
                    + "<td rowspan=\"2\" style=\"width:20px\">" + (getSize() - index) + "</td>"
                    + "<td colspan=\"3\" align=\"right\" style=\"font-size:15pt\">" + dtg.targetAfterThrows + "</td>"
                    + "</tr>"
                    + "<tr>"
                    + "<td " + getStyleString(dtg.dartMods[0]) + ">" + dtg.dartScores[0] + "</td>"
                    + "<td " + getStyleString(dtg.dartMods[1]) + ">" + dtg.dartScores[1] + "</td>"
                    + "<td " + getStyleString(dtg.dartMods[2]) + ">" + dtg.dartScores[2] + "</td>"
                    + "</tr>"
                    + "</table></html>";
            return s;
        }

        private String getStyleString(int dartMod) {
            return "style=\""
                    + "color:#ffffff;"
                    + "font-weight:bold;"
                    + "padding-right:20px;"
                    + "text-align:right;"
                    + "font-size:12pt;"
                    + "border:1px outset #" + (dartMod == 2 ? "f13327" : dartMod == 3 ? "00ab53" : "ffffff")
                    + "\"";
        }

        class DartThrowGroup {

            final int[] dartScores = new int[3];
            final int[] dartMods = new int[3];
            final int targetAfterThrows;

            public DartThrowGroup(int d1, int d1Mod, int d2, int d2Mod, int d3, int d3Mod, int targetAfterThrows) {
                this.dartScores[0] = d1;
                this.dartScores[1] = d2;
                this.dartScores[2] = d3;
                this.dartMods[0] = d1Mod;
                this.dartMods[1] = d2Mod;
                this.dartMods[2] = d3Mod;
                this.targetAfterThrows = targetAfterThrows;
            }

        }
    }

    public void logScore() {
        for (int i = 0; i < dartPanels.length; i++) {
            DartPanel d = dartPanels[i];
            if (d.requiresModifierSelection()) {
                JOptionPane.showMessageDialog(getTopLevelAncestor(),
                        "Dart " + (i + 1) + " (" + d.getSpinnerValue() + ") must be a double or treble",
                        "Dart " + (i + 1) + " (" + d.getSpinnerValue() + ")", JOptionPane.ERROR_MESSAGE);
                d.focus(true);
                return;
            }
        }
        if (newTargetValue == 0) {
            JOptionPane.showMessageDialog(getTopLevelAncestor(), playerName + " wins!", "Winner!", JOptionPane.INFORMATION_MESSAGE);
            scoreListModel.logScore();
            resetFields();
        }
        else if (isBust) {
        }
        else {
            scoreListModel.logScore();
            resetFields();
        }
    }

    public void focusFirstScoreBox() {
        this.dartPanel1.focus(true);
    }

    public void focusLastScoreBox() {
        this.dartPanel3.focus(true);
    }

    public void focusNextScoreBox(DartPanel current) {
        for (int i = 0; i < dartPanels.length; i++) {
            if (i == dartPanels.length - 1) {
                ((MainGUI) getTopLevelAncestor()).focusNextPlayerPanel(this);
            }
            else if (dartPanels[i].equals(current)) {
                dartPanels[i + 1].focus(true);
                break;
            }
        }
    }

    public void focusPreviousScoreBox(DartPanel current) {
        for (int i = dartPanels.length - 1; i >= 0; i--) {
            if (i == 0) {
                ((MainGUI) getTopLevelAncestor()).focusPreviousPlayerPanel(this);
            }
            else if (dartPanels[i].equals(current)) {
                dartPanels[i - 1].focus(true);
                break;
            }
        }
    }

    private void resetFields() {
        for (DartPanel dp : dartPanels)
            dp.resetField();
        dartPanel1.focus(true);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        previousThrowsPopup = new javax.swing.JPopupMenu();
        revertToSelected = new javax.swing.JMenuItem();
        topPanel = new javax.swing.JPanel();
        currentTarget = new javax.swing.JLabel();
        name = new javax.swing.JLabel();
        scorePanel = new javax.swing.JPanel();
        dartPanel1 = new dartstools.interfaces.DartPanel();
        dartPanel2 = new dartstools.interfaces.DartPanel();
        dartPanel3 = new dartstools.interfaces.DartPanel();
        livePanel = new javax.swing.JPanel();
        groupScore = new javax.swing.JLabel();
        newTarget = new javax.swing.JLabel();
        newTarget1 = new javax.swing.JLabel();
        newTarget2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        logPanel = new javax.swing.JPanel();
        previousThrowsScroller = new javax.swing.JScrollPane();
        previousThrows = new javax.swing.JList();

        previousThrowsPopup.setBackground(Theme.BACKGROUND);
        previousThrowsPopup.setForeground(Theme.FOREGROUND);

        revertToSelected.setBackground(Theme.BACKGROUND);
        revertToSelected.setFont(new Font(Theme.FONT_FAMILY, Font.BOLD, Theme.FONT_SMALL));
        revertToSelected.setForeground(Theme.FOREGROUND);
        revertToSelected.setText("<HTML>\nRevert to selected scores<br>\n<em>(applies across all players)</em>\n</HTML>");
        revertToSelected.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
        previousThrowsPopup.add(revertToSelected);

        setBackground(new java.awt.Color(0, 0, 0));
        setBorder(new CompoundBorder(new EmptyBorder(0,3,0,3), Theme.BORDER));
        setOpaque(false);

        topPanel.setOpaque(false);

        currentTarget.setFont(new java.awt.Font(Theme.FONT_FAMILY, Font.BOLD, Theme.FONT_LARGER));
        currentTarget.setForeground(Theme.FOREGROUND);
        currentTarget.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        currentTarget.setText(Integer.toString(this.targetScore));

        name.setFont(new java.awt.Font(Theme.FONT_FAMILY, Font.ITALIC, Theme.FONT_LARGE));
        name.setForeground(Theme.FOREGROUND);
        name.setText(this.playerName);

        javax.swing.GroupLayout topPanelLayout = new javax.swing.GroupLayout(topPanel);
        topPanel.setLayout(topPanelLayout);
        topPanelLayout.setHorizontalGroup(
            topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(topPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(name, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(currentTarget, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        topPanelLayout.setVerticalGroup(
            topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(topPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(name)
                    .addComponent(currentTarget))
                .addContainerGap())
        );

        scorePanel.setOpaque(false);

        javax.swing.GroupLayout scorePanelLayout = new javax.swing.GroupLayout(scorePanel);
        scorePanel.setLayout(scorePanelLayout);
        scorePanelLayout.setHorizontalGroup(
            scorePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(scorePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(dartPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dartPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dartPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        scorePanelLayout.setVerticalGroup(
            scorePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(scorePanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(scorePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(dartPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dartPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dartPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        livePanel.setOpaque(false);

        //groupScore.setVisible(false);
        groupScore.setFont(new Font(Theme.FONT_FAMILY, Font.PLAIN, Theme.FONT_LARGE));
        groupScore.setForeground(Theme.FOREGROUND);
        groupScore.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        groupScore.setText(Integer.toString(this.groupScoreValue));

        //newTarget.setVisible(false);
        newTarget.setFont(new Font(Theme.FONT_FAMILY, Font.PLAIN, Theme.FONT_LARGE));
        newTarget.setForeground(Theme.FOREGROUND);
        newTarget.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        newTarget.setText(Integer.toString(this.targetScore));

        //groupScore.setVisible(false);
        newTarget1.setFont(new Font(Theme.FONT_FAMILY, Font.PLAIN, Theme.FONT_MEDIUM));
        newTarget1.setForeground(Theme.FOREGROUND);
        newTarget1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        newTarget1.setText("New target:");

        //groupScore.setVisible(false);
        newTarget2.setFont(new Font(Theme.FONT_FAMILY, Font.PLAIN, Theme.FONT_MEDIUM));
        newTarget2.setForeground(Theme.FOREGROUND);
        newTarget2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        newTarget2.setText("3-dart total:");

        jButton1.setText("Enter");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout livePanelLayout = new javax.swing.GroupLayout(livePanel);
        livePanel.setLayout(livePanelLayout);
        livePanelLayout.setHorizontalGroup(
            livePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(livePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(livePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(livePanelLayout.createSequentialGroup()
                        .addGroup(livePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(newTarget2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(newTarget1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(livePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(newTarget, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(groupScore, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, livePanelLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        livePanelLayout.setVerticalGroup(
            livePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(livePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(livePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(groupScore)
                    .addComponent(newTarget2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(livePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(newTarget)
                    .addComponent(newTarget1))
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        logPanel.setBackground(new java.awt.Color(0, 0, 51));
        logPanel.setOpaque(false);

        previousThrowsScroller.setBorder(javax.swing.BorderFactory.createLineBorder(Theme.SELECTION));
        previousThrowsScroller.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        previousThrowsScroller.setToolTipText("");
        previousThrowsScroller.setMinimumSize(new java.awt.Dimension(258, 50));
        previousThrowsScroller.setOpaque(false);

        previousThrows.setModel(this.scoreListModel);
        previousThrows.setBackground(Theme.BACKGROUND);
        previousThrows.setForeground(Theme.FOREGROUND);
        previousThrows.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        previousThrows.setComponentPopupMenu(previousThrowsPopup);
        previousThrows.setOpaque(false);
        previousThrows.setSelectionBackground(Theme.SELECTION);
        previousThrows.setVisibleRowCount(6);
        previousThrows.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                previousThrowsMousePressed(evt);
            }
        });
        previousThrowsScroller.setViewportView(previousThrows);

        javax.swing.GroupLayout logPanelLayout = new javax.swing.GroupLayout(logPanel);
        logPanel.setLayout(logPanelLayout);
        logPanelLayout.setHorizontalGroup(
            logPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(logPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(previousThrowsScroller, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        logPanelLayout.setVerticalGroup(
            logPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(previousThrowsScroller, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(logPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(livePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(scorePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(topPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(topPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(scorePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(livePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(logPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        logScore();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void previousThrowsMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_previousThrowsMousePressed
        if (evt.getButton() == MouseEvent.BUTTON3) // evt.isPopupTrigger() not working
            previousThrows.setSelectedIndex(previousThrows.locationToIndex(evt.getPoint()));
    }//GEN-LAST:event_previousThrowsMousePressed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel currentTarget;
    private dartstools.interfaces.DartPanel dartPanel1;
    private dartstools.interfaces.DartPanel dartPanel2;
    private dartstools.interfaces.DartPanel dartPanel3;
    private javax.swing.JLabel groupScore;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel livePanel;
    private javax.swing.JPanel logPanel;
    private javax.swing.JLabel name;
    private javax.swing.JLabel newTarget;
    private javax.swing.JLabel newTarget1;
    private javax.swing.JLabel newTarget2;
    private javax.swing.JList previousThrows;
    private javax.swing.JPopupMenu previousThrowsPopup;
    private javax.swing.JScrollPane previousThrowsScroller;
    private javax.swing.JMenuItem revertToSelected;
    private javax.swing.JPanel scorePanel;
    private javax.swing.JPanel topPanel;
    // End of variables declaration//GEN-END:variables

    private class SpinnerListener implements ChangeListener {

        @Override
        public void stateChanged(ChangeEvent e) {
            groupScoreValue = 0;
            currentTargetValue = Integer.valueOf(currentTarget.getText());
            for (DartPanel dp : dartPanels)
                groupScoreValue += dp.getSpinnerValue();
            newTargetValue = currentTargetValue - groupScoreValue;
            isBust = newTargetValue < 0;
            newTarget.setText(isBust ? "Bust!" : newTargetValue == 0 ? "Out!" : Integer.toString(newTargetValue));
            groupScore.setText(String.valueOf(groupScoreValue));
        }

    }

    @Override
    public String toString() {
        return this.getName() + ": " + playerName;
    }
//    public static void main(String[] args) {
//        JFrame f = new JFrame();
//        f.add(new PlayerPanel("Chris", 301));
//        f.pack();
//        f.setLocationRelativeTo(null);
//        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//        f.setVisible(true);
//    }
}